package cn.car91.activity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.View;
import cn.car91.config.InitApplication;

import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.ViewUtils;

public class BaseListFragment extends ListFragment {

    DbUtils placeDbUtils;

    static InitApplication car91Application;

    public InitApplication getCar91Application() {
        return car91Application;
    }

    public interface Car91ResultCode {
        int Refresh_User_Code = 10000;
    }

	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		car91Application = (InitApplication) getActivity().getApplication();
        getActivity().registerReceiver(exitBroadcastReceiver, new IntentFilter(BaseActivity.exitAction));
		super.onViewCreated(view, savedInstanceState);
		ViewUtils.inject(this, view); //注入view和事件
	}

    @Override
	public void onDestroy() {
    	getActivity().unregisterReceiver(exitBroadcastReceiver);
        super.onDestroy();
	}

	private BroadcastReceiver exitBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context arg0, Intent arg1) {
            // TODO Auto-generated method stub
        	getActivity().finish();
        }
    };

}
